'''
A script that shows how to remove an emulated running application
from the simulation run.

@author: Hatem Oraby
'''


import twistedSim.simManager as simManager 
from twistedSim.moduleHandler import twistedH

if __name__ == '__main__':

    #Module 1
    module1 = simManager.Module('real1', twistedH(),
                                startTime = 50, sysArgs = "1 ThisIsSysArgument")
    machine1 = simManager.Machine()
    interface1 = simManager.IpInterface('176.10.0.1',machine1)
    simManager.SimManager.addModule(module1,machine1)
    
    #Module 2
    module2 = simManager.Module('real2', twistedH(), startTime = 100)
    machine2 = simManager.Machine()
    interface2 = simManager.IpInterface('42.30.125.96',machine2)
    simManager.SimManager.addModule(module2,machine2)
    
    #Remove module 1
    simManager.SimManager.callLater(150, module1.die)
    
    #Module 3
    module3 = simManager.Module('real2', twistedH(),startTime = 200)
    machine3 = simManager.Machine()
    interface3 = simManager.IpInterface('115.83.213.2',machine3)
    simManager.SimManager.addModule(module3,machine3)
    
    simManager.SimManager.run()